package com.wangc.study.functionref;

import java.util.function.BiConsumer;
import java.util.function.Consumer;

/**
 * @author wangC
 * @create 2020-05-19 下午11:16
 * 方法的引用-对象方法的调用
 **/
public class FountionRefTest3 {

    public static void main(String[] args) {
        Consumer<Too> c1 = (Too too) -> new Too().foo();
        c1.accept(new Too());
        //
        Consumer<Too> c2 = (Too too) -> new Too2().foo2();
        c2.accept(new Too());

        Consumer<Too> c3 = Too::foo;
        c3.accept(new Too());

        BiConsumer<Too2, String> bc = (too2, str) -> new Too2().add(str);
        BiConsumer<Too2,String> bc2 = Too2::add;
        bc.accept(new Too2(), "asd");
        bc2.accept(new Too2(),"qwerwq");

    }

}


class Too{

    public Integer fun(String s) {
        return 1;
    }

    public void foo() {
        System.out.println("foo");

    }
}


class Too2 {

    public Integer fun2(String s) {
        return 2;
    }

    public void foo2() {
        System.out.println("foo2");
    }

    public void add(String string) {
        System.out.println(string.length());
    }

}